fix(pre-commit-hooks): correct rev-range syntax in commitizen-branch#1841
Conversation
|
Great! Thanks for detailed analysis and explanation. |
|
I still don't think this would work. But let me just double check real quick on my end before I start babbling nonsense. |
|
Ok, yes, this does seems to work on my end as well. |
|
@pgrenaud thanks for verifying the change! |
|
Looks good to me but I haven't validate it yet |
noirbizarre
left a comment
There was a problem hiding this comment.
Good to me, fix the the current issue.
BUT, for another PR, I realize that those variables are only available in the pre-push and post-checkout stages (cf. https://pre-commit.com/#supported-git-hooks), so I think we should provide a sane default (stages: [pre-push]) to this hook (cf. https://pre-commit.com/#hooks-stages)
|
Thanks. I can help with the follow-up PR if needed. |
We probably should just add it to this PR? Or is there any concern? |
|
No concerns at all! I've just added it in this PR. |
Description
This PR fixes a regression introduced in #1815 where the
commitizen-branchpre-commit hook was incorrectly checking the entire git history instead of just the new commits on the branch.Related Issue
Fixes #1818
Problem
The previous configuration used space-separated arguments for the revision range:
When passed to
git log, this behavior acts as a union, listing all commits reachable from both references. This causedcz checkto validate historical commits that were outside the scope of the current changes.Why It's Broken
..operator: Git range syntax requires..between refsSolution
Updated the
rev-rangeargument to use the correct Git range syntaxFROM..TO:This ensures that
commitizenonly checks the commits introduced in the current branch (fromFROMup toTO).Checklist
Was generative AI tooling used to co-author this PR?
Generated-by: Gemini 3 Pro
Code Changes
uv run poe alllocally to ensure this change passes linter check and testsExpected Behavior
The
commitizen-branchpre-commit hook should only validate the specific commits being pushed or merged (the range betweenFROM_REFandTO_REF).Steps to Verify This Fix
Quick Setup
Create Test Scenario
Test the Bug vs Fix
Expected Results: